<?php
  header('Content-Type:text/html;charset=utf-8');
  require_once('class.php');
  PDOc::_connect();
  session_start();
  $id=$_SESSION['id'];
  if ($_FILES['headPic']['error']==0){
  	$file=$_FILES['headPic']['tmp_name'];
  	//echo $filename;
  	//echo $_FILES['headPic']['name'];
  	$filename=md5(date("Y-m-d H:i:s",time())).'.jpg';
  	PDOc::updateHeadPic($id,$filename);
    move_uploaded_file($file,'headPic/'.$filename);
    echo '上传成功！<br/>';
    PDOc::Button('userIndex.php','返回主页');
  } else {
  	PDOc::throwException('请选择图片！');
  	PDOc::Button('userIndex.php','返回主页');
  } 
?>